package com.pengtu.entity.business.check;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

import com.pengtu.entity.business.BasicPetition;
import com.pengtu.utils.DateUtils;

/**
 * 竣工验收质量鉴定申请书表
 * 
 * @author liuyang
 * 
 */
@Entity
@Table(name = "T_Q_CASE_COMP_PETITION")
public class CompPetition extends BasicPetition {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private FlowCompletion flowCompletion;//流程ID
	private Date detectionDate;//复测时间
	private Date acceptanceDate;//交工验收时间

	private int intYear;// 年份差,非持久化属性

	@ManyToOne(targetEntity = FlowCompletion.class, fetch = FetchType.LAZY)
	@JoinColumn(name = "FID")
	public FlowCompletion getFlowCompletion() {
		return flowCompletion;
	}

	public void setFlowCompletion(FlowCompletion flowCompletion) {
		this.flowCompletion = flowCompletion;
	}

	@Column(name = "DETECTIONDATE")
	public Date getDetectionDate() {
		return detectionDate;
	}

	public void setDetectionDate(Date detectionDate) {
		this.detectionDate = detectionDate;
	}

	@Column(name = "ACCEPTANCEDATE")
	public Date getAcceptanceDate() {
		return acceptanceDate;
	}

	public void setAcceptanceDate(Date acceptanceDate) {
		this.acceptanceDate = acceptanceDate;
	}

	@Transient
	public int getIntYear() {
		return DateUtils.getCurrentYear()
				- DateUtils.getYearofDate(acceptanceDate);
	}

	public void setIntYear(int intYear) {
		this.intYear = intYear;
	}
}
